]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Fix display keyboard layout crash with some input methods
authorPeng Wu <pwu@redhat.com>
Mon, 15 Mar 2021 06:50:31 +0000 (14:50 +0800)
committerMarge Bot <marge-bot@gnome.org>
Mon, 29 Mar 2021 09:33:45 +0000 (09:33 +0000)
Some ibus input method will use the current keyboard layout,
and return "default" as the keyboard layout.
When this happens, display the current keyboard layout instead.

Fixes #3863.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1756>

js/misc/keyboardManager.js
js/ui/status/keyboard.js

index 29fc3b76156f65c2494f22628a38a756d83c7002..142e2f41983cb336d7c46bd72eb046c208a45288 100644 (file)
@@ -156,4 +156,8 @@ var KeyboardManager = class {
         let options = this._xkbOptions.join(',');
         return options;
     }
+
+    get currentLayout() {
+        return this._current;
+    }
 };
index e34b603134d1d23311dc2339fe998e8fbb8e8163..bc50f3d3764606b048a09186a1b9cb2139620468 100644 (file)
@@ -772,6 +772,10 @@ var InputSourceManager = class {
     get inputSources() {
         return this._inputSources;
     }
+
+    get keyboardManager() {
+        return this._keyboardManager;
+    }
 };
 Signals.addSignalMethods(InputSourceManager.prototype);
 
@@ -1059,6 +1063,14 @@ class InputSourceIndicator extends PanelMenu.Button {
                 xkbLayout = engineDesc.get_layout();
                 xkbVariant = engineDesc.get_layout_variant();
             }
+
+            // The `default` layout from ibus engine means to
+            // use the current keyboard layout.
+            if (xkbLayout === 'default') {
+                const current = this._inputSourceManager.keyboardManager.currentLayout;
+                xkbLayout = current.layout;
+                xkbVariant = current.variant;
+            }
         }
 
         if (!xkbLayout || xkbLayout.length == 0)